#include <iostream>
using namespace std;

int *func()
{
  int a = 10; // 局部变量
  return &a;  // 返回局部变量的地址, 报错无法编译 address of stack memory associated with local variable 'a' returned [-Wreturn-stack-address]
}

int main(int argc, char const *argv[])
{
  int *p = func();
  cout << *p << endl;
  return 0;
}